<?php
/**
*	IMMOPHP
*	Creat on : 02/04/2010
*	Last Edition 02/04/2010
*/
require_once 'function.php';
require_once 'lang/french.php';
require_once 'header.php';

// db
require_once '../conf/config.php';
require_once '../kernel/db/class_'. $basesql['type'] .'.php';
$db = new db_sql();
$connexion = $db->sql_connect($basesql);

if(isset($_POST['send']))
{
	// Creation utilisateur dans la base
	if($_POST['password'] == '' || $_POST['password2'] == '' || $_POST['password'] != $_POST['password2'] )
	{
		redirect('page_compte_admin.php');
	}
	else
	{
		// Enregistrer dans la table
		$Query = "INSERT INTO immo_user (id, identifiant, mdp, nom, prenom, agence, email) VALUES ('1', 'admin', '". md5($_POST['password']) ."', 'admin', 'admin' , '', '')";
		$db->sql_query($Query);
        $db->sql_query("INSERT INTO immo_groupe_user_link (uid,gid) VALUES ('1','1')");
		redirect('page_config_site.php');
	}
}
else
{
	echo'<h3>'. $lang['Configuration_compte_admin'] .'</h3>
	<br /><br />
	<form method="post" action="page_compte_admin.php">
	<fieldset>
		<legend>'. $lang['Compte_admin'] .'</legend>
		<br /><br />
		<table>
			<tr>
				<td><label>'. $lang['Identifiant'] .' :</label></td>
				<td><input type="text" name="identifiant" disabled="disabled" id="identifiant" value="admin"/></td>
			</td>
			<tr>
				<td><label>'. $lang['Mot_de_passe'] .' :</label></td>
				<td><input type="password" name="password" id="password" value=""/></td>
			</td>
			<tr>
				<td><label>'. $lang['Mot_de_passe_confirmation'] .' :</label></td>
				<td><input type="password" name="password2" id="password2" value=""/></td>
			</td>
		</table>
	</fieldset>';
	echo'
	<br />
	<br />
	<div style="text-align: center;"><input type="submit" style="background:url(\'images/bleu_suivant.png\'); height:48px; width:48px; border: none; cursor: pointer; " value="" name="send"/></div>
	</form>';	
}
require_once 'footer.php';
?>